function [tc] = dec22compl(d)

    tc = dec2bin(abs(d))-48;
    tc = [tc(1) tc];
    if d < 0
       tc = negate(tc); 
    end
    
end

function X = negate(X)
    X = not(X);
    X(end) = X(end)+1;
    X = carry_propagate(X);
end

function X = carry_propagate(X)
    C = 1;
    while(sum(C)>0)
        C = X==2;
        C_LS = [C(2:end) 0];
        X(X==2) = 0;
        X = X + C_LS;
    end
end